﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AfterlifeLib;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using AfterlifeLib.Weapons;
using Afterlife.Entities;

namespace Afterlife
{
    public struct HeadsUpDisplayData
    {
        public Player Player;
        public Gun PlayerWeapon;

        public HeadsUpDisplayData(Player player, Gun playerWeapon)
        {
            Player = player;
            PlayerWeapon = playerWeapon;
        }
    }

    public class HeadsUpDisplay
    {
        SpriteFont HUDFont;
        Vector2 ShadowOffset = new Vector2(1, 1);
        Vector2 HealthPos = new Vector2(60, 650);
        Vector2 WeaponNamePos = new Vector2(1100, 650);
        Vector2 WeaponAmmoPos = new Vector2(1100, 680);

        public void LoadContent(ContentManager content)
        {
            HUDFont = content.Load<SpriteFont>("Fonts/arial14");
        }

        public void Draw(SpriteBatch spriteBatch, HeadsUpDisplayData data)
        {
            string HealthString = data.Player.Health.ToString();
            string WeaponNameString = data.PlayerWeapon.Name;
            string WeaponAmmoString = string.Format("{0} / {1}", data.PlayerWeapon.ClipAmmoLeft, data.PlayerWeapon.AmmoLeft);

            spriteBatch.Begin();
            {
                DrawString(spriteBatch, HealthPos, HealthString);
                DrawString(spriteBatch, WeaponNamePos, WeaponNameString);
                DrawString(spriteBatch, WeaponAmmoPos, WeaponAmmoString);
            }
            spriteBatch.End();
        }

        private void DrawString(SpriteBatch spriteBatch, Vector2 position, string text)
        {
            spriteBatch.DrawString(HUDFont, text, position, Color.Black);
            spriteBatch.DrawString(HUDFont, text, position + ShadowOffset, Color.White);
        }
    }
}
